<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>
<script type="text/javascript">
var dataDictDataGrid = $('#datadict-datagrid-json').datagrid({
    gridTitle : '数据字典管理',
    showLinenumber: false,
    showToolbar: true,
    filterThead: false,
    filterAll: true,
    sortAll : true,
    dataUrl: 'dataDict/list.do',
    dataType: 'json',
    columns: [
        {
            name: 'dataType',
            label: '数据类型',
            align: 'center',
            width: 200
        },
        {
            name: 'dataShowType',
            label: '数据类型名称',
            align: 'center',
            width: 200
        },
        {
			name: '',
			label: '操作',
			align: 'center',
			width: 100,
			quicksort:false,
			menu: false,
			edit: false,
			render: function(value){
		        var html = '';
		    		html += '<div class="btn-group" datadict="group"><button type="button" class="btn btn-blue btn-sm" onclick="mangeDataDictItem(this)"><i class="fa fa-edit"></i> 数据项</button></div>';
			    return html;
			}
        }
    ],
    paging: {pageSize:20, selectPageSize:'20,30,40'},
    showTfoot: true,
    fullGrid: false,
    toolbarCustom: function(){
    	var html = '';
	    	html += '<div class="btn-group" datadict="group"><button type="button" class="btn btn-green" onclick="refreshDataDictDataGrid()"><i class="fa fa-refresh"></i> 刷新</button></div>';
	    return html;
    }
});

function mangeDataDictItem(_this) {
	var dataDictIndex = $(_this).closest("tr").index();
	var data = dataDictDataGrid.data('bjui.datagrid').getRowData(dataDictIndex);
	$('#edit-datadict-dialog').dialog({
		id:'mange-dataDict-item-dialog', 
		url:'dataDict/item/index.do?dataTypeItem=' + data.dataType + '&dataShowTypeItem=' + data.dataShowType, 
		maxable: false,
		resizable:false,
		mask: true,
		width: 850,
		height: 500,
		onLoad: function($dialog){
			var $cancel = $dialog.find('.cancel');
			$cancel.click(function(){
				$dialog.dialog('closeCurrent');
			});
		},
		title:'编辑数据项-' + data.dataShowType
	});
}

function refreshDataDictDataGrid() {
	dataDictDataGrid.datagrid("refresh");
}
</script>
<div class="bjui-pageContent" id="datadict-index-pagecontent">
    <div style="padding:0px; height:100%; width:100%;">
        <table id="datadict-datagrid-json" data-width="100%" data-height="100%" class="table table-bordered">
        </table>
    </div>
</div>
<div id="edit-datadict-dialog" style="display: none;">
</div>
